#include "StdAfx.h"
#include "CircleDetect.h"


CircleDetect::CircleDetect( int camWidth ,int camHeight )
{
	this->camFram_Gray = cv::Mat::zeros( camHeight ,camWidth ,CV_8U );
	this->camFram_Edges = cv::Mat::zeros( camHeight ,camWidth ,CV_8U );

	this->gaussianKernelSize = 0;
	this->cannyLowTreshold = 0;
}

void CircleDetect::run()
{
	this->camFram_Gray.setTo(0);
	this->camFram_Edges.setTo(0);

	//original to gray level image
	cv::Mat mat( info->huroCupVision.camFrame ,0 );		//IplImage to cv::Mat
 	cv::cvtColor( mat ,camFram_Gray ,CV_BGR2GRAY );		//RGB to gray level image

	//Gaussain filter
	cv::GaussianBlur( camFram_Gray ,camFram_Edges ,cv::Size(this->gaussianKernelSize,this->gaussianKernelSize) ,3.0 );
	//cv::bilateralFilter( camFram_Gray ,camFram_Gray ,3 ,6.0 ,3.0 );

	//Canny detector
	cv::Canny( camFram_Edges ,camFram_Edges ,this->cannyLowTreshold ,this->cannyLowTreshold*3 ,3 );
	
	this->draw();
}

void CircleDetect::draw()
{
	cv::imshow( "Circle Detection" ,this->camFram_Edges );
	cv::waitKey(10);
}